#! lua
-- Nocomma
-- G.C.Wraith (07/06/2020)
local dir in riscos
local thedir = arg[1]
thedir = thedir:gsub("%.[^%.]+$","") -- ambient directory
local dirftype = 4096
local appftype = 2*dirftype
local settype = "settype %s ffd"
local rename = "rename %s %s,%03x"
local j = "%s.%s"

local cmd = { }

local scan
scan = \ (d)
      if d == arg[1] then => end -- if
      for leaf, ftype in dir (d) do
          local obj = j:format (d, leaf)
          if ftype == dirftype or ftype == appftype  then scan (obj)
          else
           cmd[1 + #cmd] = settype:format (obj)
           cmd[1 + #cmd] = rename:format (obj, obj, ftype)
          end -- if
      end -- for
    end -- function


scan (thedir)

local obey = \ (cmd)
       local execute in os
       for _,command in ipairs(cmd) do
         execute(command)
       end -- for
       end -- function

obey (cmd)



